let timer: any = null
let seconds: any = 0

addEventListener('message', (e) => {
  const { data } = e
  if (data.type == 'start') {
    timer = setInterval(function () {
      seconds++
      return postMessage({ type: 'message', seconds })
    }, 1000)
  }

  if (data.type == 'stop') {
    clearInterval(timer)
    timer = null
    seconds = 0
    return postMessage({ type: 'stop' })
  }
})
export default {}
